<template>
	<view class="hot_goods">
		<goods-list :goods="goods" @goodsItemClick="showGoods"></goods-list>
	</view>
</template>

<script>
	import goodsList from '../../components/goods-list/goods-list.vue'
	export default {
		comments:{"goodslist":goodsList},
		data() {
			return {
				goods:[],
				pageIndex:1,
			}
		},
		onLoad() {
			this.getGoods()
		},
		methods: {
			async getGoods(){
				const res = await this.$myRequest({
					url: '/api/getgoods?pageindex='+this.pageIndex
				})
				this.goods = [...this.goods,...res.data.message]
			},
			showGoods(id){
				uni.navigateTo({
					url:'../goods-detail/goods-detail?id='+id
				})
			},
		},
		onPullDownRefresh() {
			this.pageIndex = 1
			this.getGoods()
			uni.stopPullDownRefresh()
		},
		onReachBottom() {
			this.pageIndex++
			this.getGoods()
		},
		
	}
</script>

<style>

</style>
